package com.example.projectmanagement.model.study;

import com.example.projectmanagement.model.User;
import jakarta.persistence.*;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.time.LocalDateTime;

@Entity
@Table(name = "user_achievement")
@Data
@NoArgsConstructor
@AllArgsConstructor
@EntityListeners(AuditingEntityListener.class)
public class Achievement {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id", nullable = false)
    private User user;

    @Column(name = "achievement_name")
    private String achievementName; // 成就名称

    @Column(name = "achievement_type")
    private String achievementType; // 成就类型：学习类/互动类/里程碑类

    @Column(name = "description")
    private String description; // 描述

    @Column(name = "badge_icon")
    private String badgeIcon; // 徽章图标

    @CreatedDate
    @Column(name = "earned_time")
    private LocalDateTime earnedTime;
}